<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/frontSrc/lib/layui-v2.6.3/css/layui.css" media="all">

    <style>
        .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
    </style>
</head>
<body>

<blockquote class="layui-elem-quote">
    <div align="center">
        <h1 align="center">修改密码</h1><br>
        <a  href="/frontSrc/static/login.html" target="_blank" class="layui-btn layui-btn-danger">去登录</a>
    </div>
</blockquote>


<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-lg-offset3" layui-col-lg6>
            <div class="layui-form layuimini-form">

                <form class="layui-form" action="" lay-filter="studentForm">

                    <div class="layui-form-item">
                        <label class="layui-form-label">用户名:</label>
                        <div class="layui-input-block">
                            <input type="text" name="username" required lay-verify="required" placeholder="请输入用户名"
                                   autocomplete="off" class="layui-input" >
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">电话:</label>
                        <div class="layui-input-block">
                            <input type="text" name="phone" required lay-verify="required" placeholder="请输入电话"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>



                    <div class="layui-form-item">
                        <label class="layui-form-label required">密码</label>
                        <div class="layui-input-block">
                            <input type="password" name="password" lay-verify="required" lay-reqtext="新密码不能为空" placeholder="请输入新密码"  value="" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">密码</label>
                        <div class="layui-input-block">
                            <input type="password" name="passwordIs" lay-verify="required" lay-reqtext="新密码不能为空" placeholder="请重新输入新密码"  value="" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>

                </form>
            </div>

        </div>
    </div>
</div>

<script src="/frontSrc/bs/js/jquery.min.js"></script>
<script src="/frontSrc/layui/layui.js" charset="utf-8"></script>

<script>
    layui.use(["laydate","form"],function(){
        var laydate = layui.laydate;

        var form = layui.form;
        var $ = layui.jquery;



        //监听提交
        form.on('submit(formDemo)', function (data) {
            // layer.msg(JSON.stringify(data.field));

            $.ajax({
                url:"http://localhost:8080/api/user/retrievePassword",
                type:"post",
                // "headers":{"token":token},
                // contentType:"application/json",
                data: data.field,
                // result 参数 表式后台响应的数据
                success:function(result){
                    if(result.code == 200){

                        // 关闭 弹出层
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.msg("修改成功快去登录吧");
                        parent.layer.close(iframeIndex);

                    }else{
                        layer.msg(result.message);
                    }
                },
                "dataType":"json"
            });

            return false;
        });

    });


</script>
</body>
</html>